package com.uwlaser.domain;

import com.uwlaser.base.CommonModel;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.IdType;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.validation.constraints.*;
import java.math.BigDecimal;
import java.io.Serializable;
import java.util.Date;
import java.sql.Timestamp;

/**
* @author zk-Qin
* @date 2022-05-11
*/
@Data
@Builder
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@TableName("device_alarm")
public class DeviceAlarm extends CommonModel<DeviceAlarm> implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "ID")
    @TableId(type= IdType.AUTO)
    private Integer id;

    @ApiModelProperty(value = "设备编码")
    @NotBlank
    private String deviceCode;

    @ApiModelProperty(value = "设备名称")
    @NotBlank
    private String deviceName;

    @ApiModelProperty(value = "产线编码")
    @NotBlank
    private String lineCode;

    @ApiModelProperty(value = "工段编码")
    @NotBlank
    private String sectionCode;

    @ApiModelProperty(value = "工位编码")
    @NotBlank
    private String stationCode;

    @ApiModelProperty(value = "报警状态")
    @NotBlank
    private String alarmStatus;

    @ApiModelProperty(value = "故障信息")
    private String alarmMsg;

    @ApiModelProperty(value = "报警代码")
    private String alarmCode;

    @ApiModelProperty(value = "开始报警时间")
    private Date startTime;

    @ApiModelProperty(value = "结束报警时间")
    private Date endTime;

    @ApiModelProperty(value = "耗时（分）")
    private BigDecimal tripTime;

    @ApiModelProperty(value = "创建人")
    @TableField(fill= FieldFill.INSERT)
    private String createBy;

    @ApiModelProperty(value = "创建时间")
    @TableField(fill= FieldFill.INSERT)
    private Date createTime;

    @ApiModelProperty(value = "更新人")
    @TableField(fill= FieldFill.INSERT_UPDATE)
    private String updateBy;

    @ApiModelProperty(value = "更新时间")
    @TableField(fill= FieldFill.INSERT_UPDATE)
    private Date updateTime;

    public void copyFrom(DeviceAlarm source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
